/*
 * © 2010 Autodata Solutions Company. All Rights Reserved
 * This source code is the confidential and proprietary information of Autodata Solutions Company.
 * The user shall not, in whole or in part, copy, publish, disclose or make any use of this source code
 * without the prior written consent of Autodata Solutions Company.
 */
Ext.ns('net.autodata.compare.photos');
(function () {
	
	/**
	 * @class ThumbnailsPanel
	 * @extends Ext.BoxComponent
	 * @namespace net.autodata.compare.photos
	 */
	var Panel = Ext.extend(Ext.BoxComponent, {
		
		autoEl: {
			tag: 'div',
			cls: 'thumbnails-panel'
		},
		
		thumbnails: undefined,
		items: undefined,
		
		getThumbnails: function()
		{
			return this.thumbnails;
		},
		
		onRender: function ()
		{	
			var WRAPPER = net.autodata.compare.photos.IOFWrapper;
			
			Panel.superclass.onRender.apply(this, arguments);
			
			var dom = this.el.dom;
			
			this.removeAll();
			
			items = [];
			
			Ext.each(this.thumbnails, function (thumb) {				
				items.push(new WRAPPER({
					imageType: thumb.imageType,
					iofImage: thumb,
					renderTo: dom
				}));				
			}, this);
			
			this.items = items;
		},
		
		moveX: function (x)
		{
			var el = this.el;
			
			el.animate(
				{
					left: {to: x, from: el.getLeft(true)}
				},
				0.35,      // animation duration
			    null,      // callback
			    'easeOut', // easing method,
			    'run'
			);
			
		},
		
		/**
		 * @private
		 */
		removeAll: function ()
		{
			Ext.each(this.items, function (item) {
				item.destroy();
			}, this);
			delete this.items;
		}	
	});
	
	net.autodata.compare.photos.ThumbnailsPanel = Panel;
	
})();